package com.taxt.ui.activity;

import android.view.Gravity;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hjq.base.BaseDialog;
import com.hjq.shape.view.ShapeTextView;
import com.hjq.widget.layout.SettingBar;
import com.taxt.R;
import com.taxt.aop.SingleClick;
import com.taxt.app.AppActivity;
import com.taxt.other.SpUtils;
import com.taxt.ui.dialog.DateDialog;
import com.taxt.ui.dialog.DateYearDialog;
import com.taxt.ui.dialog.MenuDialog;
import com.taxt.ui.dialog.TimeDialog;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Locale;


/**
 * author : wq
 * <p>
 * time   : 2019/04/20
 * desc   : 收入纳税明细
 */
public final class DeclareDataActivity extends AppActivity {


    private LinearLayout mDeclareSearch;
    private SettingBar sbYear;
    private TextView personDataName;
    private ShapeTextView goSearchBtn;
    int endYear;
    private SettingBar sbDeclareWork;
    private SettingBar sbDeclareJob;
    private SettingBar sbDeclareNotice;
    private SettingBar sbDeclareUsed;
    boolean select1 = true;
    boolean select2 = true;
    boolean select3 = true;
    boolean select4 = true;

    @Override
    protected int getLayoutId() {
        return R.layout.declare_query_activity;
    }

    @Override
    protected void initView() {
        sbYear = (SettingBar) findViewById(R.id.sb_year);
        personDataName = (TextView) findViewById(R.id.person_data_name);
        goSearchBtn = (ShapeTextView) findViewById(R.id.go_search_btn);
        sbDeclareWork = (SettingBar) findViewById(R.id.sb_declare_work);
        sbDeclareJob = (SettingBar) findViewById(R.id.sb_declare_job);
        sbDeclareNotice = (SettingBar) findViewById(R.id.sb_declare_notice);
        sbDeclareUsed = (SettingBar) findViewById(R.id.sb_declare_used);
        setOnClickListener(sbYear, goSearchBtn, sbDeclareWork, sbDeclareJob, sbDeclareNotice, sbDeclareUsed);
    }

    @Override
    protected void initData() {
        Calendar calendar = Calendar.getInstance(Locale.CHINA);
        endYear = calendar.get(Calendar.YEAR);
        personDataName.setText(endYear + "");
    }


    @SingleClick
    @Override
    public void onClick(View view) {
        if (view == sbYear) {
            // 日期选择对话框
            new DateYearDialog.Builder(this,Calendar.getInstance(Locale.CHINA).get(Calendar.YEAR) - 2,Calendar.getInstance(Locale.CHINA).get(Calendar.YEAR))
                    .setListener(new DateYearDialog.OnListener() {
                        @Override
                        public void onSelected(BaseDialog dialog, int year, int month, int day) {
                            endYear = year;
                            personDataName.setText(endYear + "");
                        }

                        @Override
                        public void onCancel(BaseDialog dialog) {

                        }
                    })
                    .show();
        } else if (view == goSearchBtn) {
            if (!(SpUtils.decodeString("token") == null || SpUtils.decodeString("token").equals(""))) {
                PersonalDeclareDataActivity.start(this, endYear + "");
                finish();
            } else {
                startActivity(LoginActivity.class);
                finish();
            }
        } else if (view == sbDeclareWork) {
            if (select1) {
                sbDeclareWork.setLeftDrawable(R.mipmap.not_selected);
                select1 = false;
            } else {
                sbDeclareWork.setLeftDrawable(R.mipmap.seleted);
                select1 = true;
            }
        } else if (view == sbDeclareJob) {
            if (select2) {
                sbDeclareJob.setLeftDrawable(R.mipmap.not_selected);
                select2 = false;
            } else {
                sbDeclareJob.setLeftDrawable(R.mipmap.seleted);
                select2 = true;
            }
        } else if (view == sbDeclareNotice) {
            if (select3) {
                sbDeclareNotice.setLeftDrawable(R.mipmap.not_selected);
                select3 = false;
            } else {
                sbDeclareNotice.setLeftDrawable(R.mipmap.seleted);
                select3 = true;
            }
        } else if (view == sbDeclareUsed) {
            if (select4) {
                sbDeclareUsed.setLeftDrawable(R.mipmap.not_selected);
                select4 = false;
            } else {
                sbDeclareUsed.setLeftDrawable(R.mipmap.seleted);
                select4 = true;
            }
        }
    }


}